<?php
$conn = mysqli_connect("localhost","root","","fruit");
$conn->query("set names utf8");
$sql = "SELECT * FROM product ORDER BY id DESC LIMIT 0,10";
$ret = $conn->query($sql);
if (mysqli_affected_rows($conn)>0) {
	$error = 0;//0:代表的是获取数据成功
}else{
	$error = 1;//1:代表的是没有获取的数据
}
$arr = array();
while ($row = $ret->fetch_assoc()) {
	$arr[] = $row;
}
$str = json_encode($arr);
echo '{"error":'.$error.',"data":'.$str.'}';
?>
